package com.aqiang.day0528_shop.sql

import android.content.Context
import android.database.sqlite.SQLiteDatabase
import org.jetbrains.anko.db.ManagedSQLiteOpenHelper

class UserInfo(con:Context) : ManagedSQLiteOpenHelper(con,"info.db",null,1) {
    companion object {
        val sqlName:String = "info"
        var userInfo:UserInfo? = null

        @Synchronized
        fun getInstance(c:Context):UserInfo{
            if(userInfo == null){
                userInfo = UserInfo(c)
            }
            return userInfo!!
        }
    }
    override fun onCreate(db: SQLiteDatabase?) {
        db!!.execSQL("create table ${sqlName} (id Integer Primary key autoincrement,name varchar(10),tel varchar(11),area varchar(30),address varchar(50))")
    }

    override fun onUpgrade(db: SQLiteDatabase?, oldVersion: Int, newVersion: Int) {

    }
}